/*
 * simple utilities
 *
 * Choi Jonghwan <saxboy@gmail.com>
 * 2006/04/24
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include "util.h"

int get_random_number(int range)
{
	int rand_dev=0; 
	unsigned int num=0; 

	if ( (rand_dev = open("/dev/random", O_RDONLY))< 0 )
		return 0; 

	read(rand_dev, &num, sizeof(int) ); 

	return ( num % range ); 
}

#if 0
int main()
{
	int i=0; 
	for (i=0; i<10; i++)
	{
		printf("%d\n", get_random_number(100) ); 
	}
}
#endif
